myApp.controller("firstController",function($scope){
	$scope.firstName = "John";
    $scope.lastName = "Doe";
	$scope.names=[
			{name:'Jani',country:'Norway'},
			{name:'Hege',country:'Sweden'},
			{name:'Kai',country:'Denmark'}];
			
	$scope.num="3432432.546546546";		
})

myApp.controller("secondController",function($scope,$http,$attrs){
	    $http.get($attrs.url)
		.success(function(response) {$scope.names = response;});
})

/*时钟的控制器*/
myApp.controller("thirdController",function($scope){
	$scope.clock={
		now:new Date()
	};
	
	var updateClock = function() {
		$scope.clock.now = new Date()
	};
	
	setInterval(function() {
		$scope.$apply(updateClock);
	}, 1000);
	
})
/*点击控制器 */
myApp.controller('clickController', function($scope) {
$scope.counter = 0;
$scope.add = function(amount) { $scope.counter += amount; };
$scope.subtract = function(amount) { $scope.counter -= amount; };
});

/*动态生成表单*/
myApp.controller('FormController',function($scope) {
$scope.fields = [
{placeholder: 'Username', isRequired: true},
{placeholder: 'Password', isRequired: true},
{placeholder: 'Email (optional)', isRequired: false}
];
$scope.submitForm = function() {
alert("it works!");
};
});


/*提交表单*/
myApp.controller("ActionController",function($scope,$http,$attrs){
	$scope.submitForm=function(){
		console.log($attrs);
	$http({
			method: "post",
			url		: $attrs.actionUrl,
			data     : $.param($scope.formData), 
			headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
	}).success(function(data){
		 console.log(data);
	})
	
}
	
})



